home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / doc / ExprLong.3 < prev    next >
Text File  |  1993-02-14  |  4KB  |  101 lines

  1. '\"
  2. '\" Copyright 1989 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. .so man.macros
  11. .HS Tcl_ExprLong tcl
  12. .BS
  13. .SH NAME
  14. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString \- evaluate an expression
  15. .SH SYNOPSIS
  16. .nf
  17. \fB#include <tcl.h>\fR
  18. .VS
  19. .sp
  20. int
  21. \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
  22. .sp
  23. int
  24. \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
  25. .sp
  26. int
  27. \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
  28. .sp
  29. int
  30. \fBTcl_ExprString\fR(\fIinterp, string\fR)
  31. .SH ARGUMENTS
  32. .AS Tcl_Interp *booleanPtr
  33. .AP Tcl_Interp *interp in
  34. Interpreter in whose context to evaluate \fIstring\fR.
  35. .AP char *string in
  36. Expression to be evaluated.  Must be in writable memory (the expression
  37. parser makes temporary modifications to the string during parsing, which
  38. it undoes before returning).
  39. .AP long *longPtr out
  40. Pointer to location in which to store the integer value of the
  41. expression.
  42. .AP int *doublePtr out
  43. Pointer to location in which to store the floating-point value of the
  44. expression.
  45. .AP int *booleanPtr out
  46. Pointer to location in which to store the 0/1 boolean value of the
  47. expression.
  48. .BE
  49.  
  50. .SH DESCRIPTION
  51. .PP
  52. These four procedures all evaluate a string expression, returning
  53. the result in one of four different forms.
  54. The expression is given by the \fIstring\fR argument, and it
  55. can have any of the forms accepted by the \fBexpr\fR command.
  56. The \fIinterp\fR argument refers to an interpreter used to
  57. evaluate the expression (e.g. for variables and nested Tcl
  58. commands) and to return error information.  \fIInterp->result\fR
  59. is assumed to be initialized in the standard fashion when any
  60. of the procedures are invoked.
  61. .PP
  62. For all of these procedures the return value is a standard
  63. Tcl result:  \fBTCL_OK\fR means the expression was succesfully
  64. evaluated, and \fBTCL_ERROR\fR means that an error occurred while
  65. evaluating the expression.  If \fBTCL_ERROR\fR is returned then
  66. \fIinterp->result\fR will hold a message describing the error.
  67. If an error occurs while executing a Tcl command embedded in
  68. \fIstring\fR, then that error will be returned.
  69. .PP
  70. If the expression is successfully evaluated, then its value will
  71. be returned in one of four forms, depending on which procedure
  72. is invoked.
  73. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
  74. If the expression's actual value was a floating-point number,
  75. then it is truncated to an integer.
  76. If the expression's actual value was a non-numeric string then
  77. an error is returned.
  78. .PP
  79. \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
  80. If the expression's actual value was an integer, it is converted to
  81. floating-point.
  82. If the expression's actual value was a non-numeric string then
  83. an error is returned.
  84. .PP
  85. \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
  86. If the expression's actual value was an integer or floating-point
  87. number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if
  88. the value was zero and 1 otherwise.
  89. If the expression's actual value was a non-numeric string then
  90. an error is returned.
  91. .PP
  92. \fBTcl_ExprString\fR returns the value of the expression as a
  93. string stored in \fIinterp->result\fR.
  94. If the expression's actual value was an integer or floating-point
  95. number, then \fBTcl_ExprString\fR converts it to string (using \fBsprintf\fR
  96. with a ``%d'' or ``%g'' converter).
  97.  
  98. .SH KEYWORDS
  99. boolean, double, evaluate, expression, integer, string
  100. .VE
  101.